<template>
    <div class="px-4 py-8">
        <a-table :dataSource="dataSource" :columns="columns" />
    </div>
</template>

<script setup lang="ts">
import { useRequest } from "alova/client";

import { useUserStore } from "@/stores/user";

const columns = [
    {
        title: "序号",
        dataIndex: "index",
        key: "index"
    },
    {
        title: "ID",
        dataIndex: "key",
        key: "key"
    },
    {
        title: "内容",
        dataIndex: "content",
        key: "content"
    },
    {
        title: "发布时间",
        dataIndex: "createdAt",
        key: "createdAt"
    }
];

const userStore = useUserStore();

const { data } = useRequest(Apis.Comments.page({ params: { userId: userStore.userinfo.id } }));

const dataSource = computed(() => {
    return data.value?.data.list.map((item, index) => ({
        index: index + 1,
        key: item.id,
        content: item.content,
        createdAt: item.createdAt
    }));
});
</script>

<style scoped lang="scss"></style>
